package cn.yfxu.config;

import cn.yfxu.quartz.TestTask;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail testQuartz() {
        return JobBuilder.newJob(TestTask.class).withIdentity("testTask").storeDurably().build();
    }

    @Bean
    public Trigger testQuartzTrigger() {
        //10秒执行一次
        return TriggerBuilder.newTrigger().forJob(testQuartz())
                .withIdentity("testTask")
                .withSchedule(CronScheduleBuilder.cronSchedule("*/10 * * * * ?"))
                .build();

    }
}
